Britain had a functioning consular service in Japan from 1859 after the signing of the 1858 Anglo-Japanese Treaty of Amity and Commerce between James Bruce, 8th Earl of Elgin and the Tokugawa Shogunate until 1941 when war was declared by Britain on Japan as the ally of the United States after the Attack on Pearl Harbor.